package BusquedaLocal;
import IA.Bicing.Bicing;
import aima.search.framework.Problem;
import aima.search.framework.Search;
import aima.search.framework.SearchAgent;
import aima.search.informed.HillClimbingSearch;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        /*
        int est = Integer.parseInt(args[1]);
        int bic = Integer.parseInt(args[2]);
        int dem = Integer.parseInt(args[3]);
        int furgos = Integer.parseInt(args[3]);
        
        Bicing b = new Bicing(est,bic,dem);
        Board board = new Board(b, furgos);
        */
        Bicing b = new Bicing(30,1500,100,400);
        Board board = new Board(b, 15);
        HillClimbingSearch(board);
    }

    private static void HillClimbingSearch(Board b) {
        System.out.println("\nBicing HillClimbing  -->");
        try {
            Problem problem =  new Problem(b,new LSSuccessorFunction(),
                    new LSGoalTest(),new LSHeuristicFunction());
            Search search =  new HillClimbingSearch();
            SearchAgent agent = new SearchAgent(problem,search);
            System.out.println();
            printActions(agent.getActions());
            printInstrumentation(agent.getInstrumentation());
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    private static void printInstrumentation(Properties properties) {
        Iterator keys = properties.keySet().iterator();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            String property = properties.getProperty(key);
            System.out.println(key + " : " + property);
        }

    }

    private static void printActions(List actions) {
        for (int i = 0; i < actions.size(); i++) {
            String action = (String) actions.get(i);
            System.out.println(action);
            System.out.println();
        }
    }


}
